# Contributor: Alexander Belkov <msun00@yandex.ru>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Alexander Belkov <msun00@yandex.ru>
pkgname=at
pkgver=3.2.5
pkgrel=2
pkgdesc="AT and batch delayed command scheduling utility and daemon"
url="http://blog.calhariz.com/index.php?tag/at"
arch="all"
options="!check suid"  # No test suite.
license="GPL-2.0-or-later"
makedepends="ssmtp flex-dev byacc"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="http://software.calhariz.com/at/at_$pkgver.orig.tar.gz
	0001-opt_V.patch
	0004-shell-add-preceding-newline-to-delimiter.patch
	0008-aborted-jobs.patch
	0009-noabort.patch
	0010-fclose-error.patch
	0011-clear-nonjobs.patch
	0012-lock-locks.patch
	0013-log-jobs.patch
	10-Makefile.in-1.patch
	at.allow
	atd.initd
	atd.confd
	"

prepare() {
	default_prepare
	update_config_guess
	update_config_sub
}

build() {
	LEXLIB=-lfl \
	./configure \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--runstatedir=/run \
		--with-daemon_username=at \
		--with-daemon_groupname=at \
		--with-jobdir=/var/spool/atd \
		--with-atspool=/var/spool/atd
	make
}

package() {
	install -D -o root -g at -m 640 "$srcdir"/at.allow "$pkgdir"/etc/at.allow

	make IROOT="$pkgdir" install

	# This file is created by post-install script, if not exist yet.
	rm "$pkgdir"/var/spool/atd/.SEQ

	install -m 755 -D "$srcdir"/atd.initd "$pkgdir"/etc/init.d/atd
	install -m 644 -D "$srcdir"/atd.confd "$pkgdir"/etc/conf.d/atd
}

sha512sums="
542e8948bbdc1d06934070cbfe242688b541ef6342c6b0351255f8b9d7a3ed915a9304b5cf5442dfc15845b3d2b926ebecbfc5bccd204519d0a2775b27f8139c  at_3.2.5.orig.tar.gz
169ec4e96667108b432f50921ed46c030b00ce5d0e87835e0548032baea4b7e53104b8e369ebb54f71afd0bdb292dd3f3de5bd3533bbea192a850699e9bab0a2  0001-opt_V.patch
33f862066cb12353c0d9096a31d82ada291dcecb0b953d4ca31d8f66659c1a09752146601900d961ac93fd8238663394cf49581d4fb5e62456e4ea7c82d702cd  0004-shell-add-preceding-newline-to-delimiter.patch
aab7630963a432fc8a125d053db5af4c97b12485792cc7dbca2d70f267edeccd50dfb592a5c9d1e49884d71cba7421830e9c82fb0e7c4cc7773f3dab95ac97d0  0008-aborted-jobs.patch
7c571b70ce081ca212ce214f3219c416a3e3f1b4d69894d490f275a6fb289a6d60a91059e969369c0be404a1ca38068b176b70c9576ae2b5295b2e2624066fd8  0009-noabort.patch
665d36415cb218dc6676066f5be18a9973ca91f68f317a209ec280f83195990929cacd301ec9aaf408b7777e2d67aa6247ad99bc723e9ef579f83cf91f7904e7  0010-fclose-error.patch
1d22e43e0017c77c66658a0d6b57015e7d77c93ff7912e96d1a969e6dc31de51e1084f1cb64959d94ed2e49b3879ce384ea6307715afcb53f474d44dba6ffde3  0011-clear-nonjobs.patch
d8b01a74c1f8623d3df0d3357085bb747ee629b3483235304b2fc8bbac944340045ee507e735c70a9acc9ad51416d67432599634ecc3af348e44041fec49e1e8  0012-lock-locks.patch
24e253dd02398a23538a2468fc0c93fc7d592e3079bd6dc141ccded8de4d02a790a02b8ff1d92df683f402cc692393e5855388f2c96b363faef24b962e96f4d4  0013-log-jobs.patch
ba57e93c9c90dc989e8ac299c12de13de0005b28fd934620a9a5b47af89db3c0dc63e39043ab3a50d313ed2bb4f4832b1f68db971b3f515c500a2b74ed18acbd  10-Makefile.in-1.patch
21e1bc024bd76c76b68e04614c6def5b03fd4b658e59bfde065b464b520f463711b795455e3a5c81a8a1946b2bca2f83d6c19300a4d3326ce17959a7cbc0846a  at.allow
247f732ded979f0a0cc31a5ff79b91a7cf1c38013e35b7c1b707e55d303b0252a2c8d270e9d875c3cb7d891c88835e63a94a00ee8b34b83b25fcdb3f80ad6e24  atd.initd
728bdd4d4ce011bb6c699f1682974c21b29b6cbe5fd27c7f7185d621764856831721ecc515eec59bcb9efa271c015ba2d924c2a1dd1d06182faaf5a9228cd7c8  atd.confd
"
